Hello
How can I save an excel file using an dxl command at the end of the export ?
Thank you
izzo - Mon Feb 21 05:22:44 EST 2011 |
|
Re: Save Excel file SystemAdmin - Mon Feb 21 12:51:29 EST 2011
Use the Excel functions package from Baselines Inc DXL repository. The package contains functions saveFile / saveFileAs.
|
|
Re: Save Excel file izzo - Tue Feb 22 06:10:49 EST 2011 SystemAdmin - Mon Feb 21 12:51:29 EST 2011
Use the Excel functions package from Baselines Inc DXL repository. The package contains functions saveFile / saveFileAs.
Hey thanks for the file
I did :
string filename=name(current Module)
clear(objArgBlock)
put(objArgBlock, "FileName", filename)
oleMethod(objExcelWorkbook, "SaveAs", objArgBlock)// it works
oleMethod(objExcelWorkbook,"Close",objArgBlock) // it works
oleMethod(objExcelApplication,"Quit",objArgBlock) //does not work
oleMethod(objExcelApplication,"Close",objArgBlock) //does not work
The workgroup close, but my excel application doest not close, is it possible to close it by a command ?
It is also weird that when I close it manually , EXCEL.EXE is still running
|
|
Re: Save Excel file Mathias Mamsch - Tue Feb 22 07:40:00 EST 2011 izzo - Tue Feb 22 06:10:49 EST 2011
Hey thanks for the file
I did :
string filename=name(current Module)
clear(objArgBlock)
put(objArgBlock, "FileName", filename)
oleMethod(objExcelWorkbook, "SaveAs", objArgBlock)// it works
oleMethod(objExcelWorkbook,"Close",objArgBlock) // it works
oleMethod(objExcelApplication,"Quit",objArgBlock) //does not work
oleMethod(objExcelApplication,"Close",objArgBlock) //does not work
The workgroup close, but my excel application doest not close, is it possible to close it by a command ?
It is also weird that when I close it manually , EXCEL.EXE is still running
The reason excel is not closing is, that there are active OLE references, which make the OLE server stay alive even after the Application closes. The only way around this is to consequently free all OLE handles with oleCloseAutoObject. This is very tedious try and error work. I am not sure about the conditions when you need to close a handle and when not.
Regards, Mathias
Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS
|
|
Re: Save Excel file izzo - Tue Feb 22 09:00:54 EST 2011 Mathias Mamsch - Tue Feb 22 07:40:00 EST 2011
The reason excel is not closing is, that there are active OLE references, which make the OLE server stay alive even after the Application closes. The only way around this is to consequently free all OLE handles with oleCloseAutoObject. This is very tedious try and error work. I am not sure about the conditions when you need to close a handle and when not.
Regards, Mathias
Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS
string filename=name(current Module)
clear(objArgBlock)
put(objArgBlock, "FileName", filename)
oleMethod(objExcelWorkbook, "SaveAs", objArgBlock)
// oleMethod(objExcelDataExportSheet,"Close",objArgBlock)
oleCloseAutoObject(objExcelDataExportSheet)
oleCloseAutoObject(objExcelOLEExportSheet)
oleCloseAutoObject(objExcelWorkbook)
oleCloseAutoObject(objExcelWorkbooks)
oleCloseAutoObject(objExcelApplication) // It seems that this does not work
OK EXCEL.EXE killed, only after i close manually the application,
The workbook closes automatically, how to close also automatically the Excel application ?? It is an empty black Excel application
|
|
Re: Save Excel file Mathias Mamsch - Tue Feb 22 10:38:25 EST 2011 izzo - Tue Feb 22 09:00:54 EST 2011
string filename=name(current Module)
clear(objArgBlock)
put(objArgBlock, "FileName", filename)
oleMethod(objExcelWorkbook, "SaveAs", objArgBlock)
// oleMethod(objExcelDataExportSheet,"Close",objArgBlock)
oleCloseAutoObject(objExcelDataExportSheet)
oleCloseAutoObject(objExcelOLEExportSheet)
oleCloseAutoObject(objExcelWorkbook)
oleCloseAutoObject(objExcelWorkbooks)
oleCloseAutoObject(objExcelApplication) // It seems that this does not work
OK EXCEL.EXE killed, only after i close manually the application,
The workbook closes automatically, how to close also automatically the Excel application ?? It is an empty black Excel application
Remember: oleCloseAutoObject() will just invalidate the OLE handle, not close the application. Therefore you need first to invalidate all child handles. Then call "Quit" / "Close" on the excel Application.
Read for example this for a little background info on the problem.
Try the below. Hope this helps, Regards,Mathias
string filename=name(current Module)
clear(objArgBlock)
put(objArgBlock, "FileName", filename)
oleMethod(objExcelWorkbook, "SaveAs", objArgBlock)
oleCloseAutoObject(objExcelDataExportSheet)
oleCloseAutoObject(objExcelOLEExportSheet)
oleCloseAutoObject(objExcelWorkbook)
oleCloseAutoObject(objExcelWorkbooks)
oleMethod(objExcelApplication,"Quit") // It seems that should work, except you have more references dangling...
oleCloseAutoObject(objExcelApplication)
Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS
|
|
Re: Save Excel file izzo - Wed Feb 23 04:24:01 EST 2011 Mathias Mamsch - Tue Feb 22 10:38:25 EST 2011
Remember: oleCloseAutoObject() will just invalidate the OLE handle, not close the application. Therefore you need first to invalidate all child handles. Then call "Quit" / "Close" on the excel Application.
Read for example this for a little background info on the problem.
Try the below. Hope this helps, Regards,Mathias
string filename=name(current Module)
clear(objArgBlock)
put(objArgBlock, "FileName", filename)
oleMethod(objExcelWorkbook, "SaveAs", objArgBlock)
oleCloseAutoObject(objExcelDataExportSheet)
oleCloseAutoObject(objExcelOLEExportSheet)
oleCloseAutoObject(objExcelWorkbook)
oleCloseAutoObject(objExcelWorkbooks)
oleMethod(objExcelApplication,"Quit") // It seems that should work, except you have more references dangling...
oleCloseAutoObject(objExcelApplication)
Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS
References means more Excel objects not killed running in memory?
|
|
Re: Save Excel file Mathias Mamsch - Wed Feb 23 07:46:36 EST 2011 izzo - Wed Feb 23 04:24:01 EST 2011
References means more Excel objects not killed running in memory?
Generally every excel.exe instance started will be a separate process and stay alive until you call "quit" on it.
That given, all OLE handles (i.e. all OleAutoObjects) have a reference count. The server should stay alive as long as there are still references to the objects. The bad thing is, that it is not clear how DOORS will handle those references, as soon as your program quits. It is also not clear which references Excel will free, so I strongly suggest you keep freeing those handles by oleCloseAutoObject.
Example:
// Create Excel object and get workbooks
OleAutoObj x = oleCreateAutoObject "Excel.Application"; olePut (x, "Visible", true)
OleAutoObj wbs = null; oleGet(x,"Workbooks", wbs)
// add a workbook and get activesheet
OleAutoArgs args = create(); OleAutoObj wb; put (args, 1); oleMethod (wbs, "Add", args, wb)
OleAutoObj shid; print " activeSheet" oleGet(x, "ActiveSheet", shid)
// Add a chart object - if the chart object is not there, everything will be fine
OleAutoObj charts,ch; print " getChartObjects " oleGet(shid, "ChartObjects", charts)
clear args; put(args, 100); put (args, 200); put(args, 100); put (args, 200);
print "add" oleMethod (charts, "Add", args, ch)
// Now it gets intersting. If you do not free the chart handle, then excel will stay alive!
// Comment this out
oleCloseAutoObject ch
// But this will only happen, if you do this. Comment that out and excel will quit nicly again.
olePut (wb, "Saved", true)
ack "About to close. Check your task manager"; print oleMethod (x, "Quit")
So you see, it is hard to tell what exactly is going on. So I really can only repeat. Free your handles ;-) Hope this helps, regards, Mathias
Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS
|
|
Re: Save Excel file izzo - Wed Feb 23 08:13:53 EST 2011 Mathias Mamsch - Wed Feb 23 07:46:36 EST 2011
Generally every excel.exe instance started will be a separate process and stay alive until you call "quit" on it.
That given, all OLE handles (i.e. all OleAutoObjects) have a reference count. The server should stay alive as long as there are still references to the objects. The bad thing is, that it is not clear how DOORS will handle those references, as soon as your program quits. It is also not clear which references Excel will free, so I strongly suggest you keep freeing those handles by oleCloseAutoObject.
Example:
// Create Excel object and get workbooks
OleAutoObj x = oleCreateAutoObject "Excel.Application"; olePut (x, "Visible", true)
OleAutoObj wbs = null; oleGet(x,"Workbooks", wbs)
// add a workbook and get activesheet
OleAutoArgs args = create(); OleAutoObj wb; put (args, 1); oleMethod (wbs, "Add", args, wb)
OleAutoObj shid; print " activeSheet" oleGet(x, "ActiveSheet", shid)
// Add a chart object - if the chart object is not there, everything will be fine
OleAutoObj charts,ch; print " getChartObjects " oleGet(shid, "ChartObjects", charts)
clear args; put(args, 100); put (args, 200); put(args, 100); put (args, 200);
print "add" oleMethod (charts, "Add", args, ch)
// Now it gets intersting. If you do not free the chart handle, then excel will stay alive!
// Comment this out
oleCloseAutoObject ch
// But this will only happen, if you do this. Comment that out and excel will quit nicly again.
olePut (wb, "Saved", true)
ack "About to close. Check your task manager"; print oleMethod (x, "Quit")
So you see, it is hard to tell what exactly is going on. So I really can only repeat. Free your handles ;-) Hope this helps, regards, Mathias
Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS
Or simply do
system("taskkill /F /IM excel.exe")
I modified completely the script enhanced export to excel, I did a browser that let you chose 1 or n baselines from different modules, and the export is done automatically for each baseline chosen.
Each module (baseline) exported to excel is saved under the name of the module-version baselines.
I will kill the automatically EXCEL.EXE after the Excel application quit
The only thing not to do is to have another Excel files open in the same time
Danke !
|
|
Re: Save Excel file llandale - Wed Feb 23 09:40:23 EST 2011 izzo - Wed Feb 23 08:13:53 EST 2011
Or simply do
system("taskkill /F /IM excel.exe")
I modified completely the script enhanced export to excel, I did a browser that let you chose 1 or n baselines from different modules, and the export is done automatically for each baseline chosen.
Each module (baseline) exported to excel is saved under the name of the module-version baselines.
I will kill the automatically EXCEL.EXE after the Excel application quit
The only thing not to do is to have another Excel files open in the same time
Danke !
This is all beyond me, but I know I had serious issues with this stuff when perhaps there was more than one excel running on the PC.
|
|
Re: Save Excel file Mathias Mamsch - Wed Feb 23 11:08:24 EST 2011 izzo - Wed Feb 23 08:13:53 EST 2011
Or simply do
system("taskkill /F /IM excel.exe")
I modified completely the script enhanced export to excel, I did a browser that let you chose 1 or n baselines from different modules, and the export is done automatically for each baseline chosen.
Each module (baseline) exported to excel is saved under the name of the module-version baselines.
I will kill the automatically EXCEL.EXE after the Excel application quit
The only thing not to do is to have another Excel files open in the same time
Danke !
Yeah ... No ... Bad idea! At least if that is a script that other people shall use. You should tell those users to save their work, that he has opened in other excel applications before you do this ;-) People start to react pi55ed if they loose the work of some hours, just because they did some excel export. For the same reason you should never use "oleGetAutoObject" (like a lot of excel libraries I saw do, to at least open only one background excel, when you run the script), because then the export will hijack the user session (and maybe close it afterwards, or start modifying data in it).
Regards, Mathias
Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS
|
|
Re: Save Excel file rmoskwa - Wed Feb 23 16:37:32 EST 2011 izzo - Wed Feb 23 08:13:53 EST 2011
Or simply do
system("taskkill /F /IM excel.exe")
I modified completely the script enhanced export to excel, I did a browser that let you chose 1 or n baselines from different modules, and the export is done automatically for each baseline chosen.
Each module (baseline) exported to excel is saved under the name of the module-version baselines.
I will kill the automatically EXCEL.EXE after the Excel application quit
The only thing not to do is to have another Excel files open in the same time
Danke !
This information (50 ways to kill Excel) may be helpful, then again, it may not
Link: http://devcity.net/printarticle.aspx?articleid=239
|
|